<#include "/public/macro.html">
<div class="uk-layui-form">
	<form class="layui-form layui-form-pane" action="/apps/xiaoe/scene/update.html" method="post">
		<#if type??><input type="hidden" name="type" value="${type!''}"></#if>
		<input type="hidden" name="id" value="${scene.id!''}">
		<div class="layui-collapse">
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">对话信息</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">标题：</label>
							<div class="layui-input-inline" style="width: 664px;">
								<input type="text" name="title" autocomplete="off" class="layui-input" value="${scene.title!''}" required="required" lay-verify="required" maxlength="255">
								
							</div>
						</div>
						<div class="layui-inline">
							<label style="color:red;">* 必填项</label>
						</div>
					</div>
					<div class="layui-form-item" pane>
						<div class="layui-inline">
							<label class="layui-form-label">回复策略：</label>
							<div class="layui-input-block">
								<input type="radio" name="replaytype" value="random" title="随机" <#if scene.replaytype?? && scene.replaytype == "random">checked</#if>>
								<input type="radio" name="replaytype" value="order" title="顺序" <#if scene.replaytype?? && scene.replaytype == "order">checked</#if>>
								<input type="radio" name="replaytype" value="same" title="与提问对应的位置" <#if scene.replaytype?? && scene.replaytype == "same">checked</#if>>
							</div>
						</div>
						<div class="layui-inline">
							<label style="color:#cccccc;">“AI回复”有多条的情况下的回复内容选取方式</label>
						</div>
					</div>
					<div class="layui-form-item" pane>
						<div class="layui-inline">
							<label class="layui-form-label">多轮对话：</label>
							<div class="layui-input-block">
								<input type="radio" name="accept" value="1" title="启用" <#if scene.accept>checked</#if>>
								<input type="radio" name="accept" value="0" title="禁用" <#if scene.accept == false>checked</#if>>
							</div>
						</div>
						<div class="layui-inline">
							<label style="color:#cccccc;">“AI” 启用多轮对话功能</label>
						</div>
					</div>
					
					<div class="layui-form-item" pane>
						<div class="layui-inline">
							<label class="layui-form-label">转人工：</label>
							<div class="layui-input-inline" style="width:90px;">
								<input type="checkbox" name="staticagent" value="1" <#if scene.staticagent?? && scene.staticagent == true>checked="checked"</#if> lay-skin="switch" lay-text="ON|OFF">
							</div>
						</div>
						<div class="layui-inline">
							<label style="color:#cccccc;">“AI” 触发无感知转人工</label>
						</div>
					</div>
					
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">信息采集：</label>
							<div class="layui-input-inline" style="width:auto;">
								<input type="checkbox" name="bussop" value="1" lay-skin="switch" lay-filter="bussop" lay-text="ON|OFF" <#if scene.bussop?? && scene.bussop == true>checked="checked"</#if>>
							</div>
						</div>
						<div class="layui-inline" style="<#if !(scene.bussop??) || scene.bussop == false>display:none;</#if>" id="bussop_tip">
							<div class="layui-input-inline" style="width:100%;padding-top:0px;">
								<#if bussOpList??>
								<#list bussOpList as op>
								<input type="checkbox" name="busslist" title="${op.name!''}" value="${op.code!''}" lay-skin="primary" <#if scene.busslist?? && scene.busslist?index_of(op.code) gte 0>checked="checked"</#if>>
								</#list>
								</#if>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="layui-colla-item" pane>
				<h2 class="layui-colla-title">对话条件</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">输入条件：</label>
							<div class="layui-input-inline" style="width: 664px;">
								<select lay-ignore name="inputcon" class="ukefu-select" placeh style="width: 100%" readonly="readonly" multiple="multiple">
								 	<#if inputConList??>
								 	<#list inputConList as input>
								 	<option value="${input.id!''}" <#if scene.inputcon?? && scene.inputcon?index_of(input.id) gte 0>selected="selected"</#if>>${input.name!''}</option>
								 	</#list>
								 	</#if>
								</select>
							</div>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">输出条件：</label>
							<div class="layui-input-inline" style="width: 664px;">
								<select lay-ignore name="outputcon" class="ukefu-select" placeh style="width: 100%" readonly="readonly" multiple="multiple">
								 	<#if outputConList??>
								 	<#list outputConList as output>
								 	<option value="${output.code!''}" <#if scene.outputcon?? && scene.outputcon?index_of(output.code) gte 0>selected="selected"</#if>>${output.name!''}</option>
								 	</#list>
								 	</#if>
								</select>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- 
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">触发动作</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">标题：</label>
							<div class="layui-input-inline">
								<input type="text" name="title" autocomplete="off"
									class="layui-input" required="required" lay-verify="required"
									maxlength="255">

							</div>
						</div>
						<div class="layui-inline">
							<label style="color:red;">* 必填项</label>
						</div>
					</div>
				</div>
			</div>
			 -->

			<div class="layui-colla-item" pane>
				<h2 class="layui-colla-title">用户输入</h2>
				<div class="layui-colla-content layui-show" id="userinput">
					<#if sceneItemList??>
					<#assign userinput = 0>
					<#list sceneItemList as sceneItem>
					<#if sceneItem.itemtype?? && sceneItem.itemtype == "userinput">
					<#assign userinput = userinput+1>
					<div class="layui-form-item">
						<label class="layui-form-label">用户输入：</label>
						<input type="hidden" name="userinput" value="${sceneItem.content!''}">
						<div class="layui-input-inline" style="width: 664px;min-height: 26px;color:#000000;border: 1px solid #dedede;padding:5px;" contenteditable="true" onblur="$(this).prev().val($(this).text());">
							${sceneItem.content!''}
						</div>
						<div class="layui-inline ukefu-group-op">
							<a href="javascript:void(0)" onclick="$('#userinput').append($(this).closest('.layui-form-item').prop('outerHTML'));">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#xe608;</i></label>
							</a>
							<#if userinput gt 0>
							<a href="javascript:void(0)" onclick="$(this).closest('.layui-form-item').remove();" class="ukefu-group-remove">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#x1006;</i></label>
							</a>
							</#if>
						</div>
					</div>
					</#if>
					</#list>
					</#if>
					<#if userinput == 0>
					<div class="layui-form-item">
						<label class="layui-form-label">用户输入：</label>
						<input type="hidden" name="userinput" value="">
						<div class="layui-input-inline" style="width: 664px;min-height: 26px;color:#000000;border: 1px solid #dedede;padding:5px;" contenteditable="true" onblur="$(this).prev().val($(this).text());">
						</div>
						<div class="layui-inline ukefu-group-op">
							<a href="javascript:void(0)" onclick="$('#userinput').append($(this).closest('.layui-form-item').prop('outerHTML'));">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#xe608;</i></label>
							</a>
							<a href="javascript:void(0)" onclick="$(this).closest('.layui-form-item').remove();" class="ukefu-group-remove">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#x1006;</i></label>
							</a>
						</div>
					</div>
					</#if>
				</div>
			</div>
			<div class="layui-colla-item" pane>
				<h2 class="layui-colla-title">AI回复</h2>
				<div class="layui-colla-content layui-show" id="airp">
					<#if sceneItemList??>
					<#assign aireply = 0>
					<#list sceneItemList as sceneItem>
					<#if sceneItem.itemtype?? && sceneItem.itemtype == "aireply">
					<#assign aireply = aireply+1>
					<div class="layui-form-item">
						<label class="layui-form-label">AI回复：</label>
						<input type="hidden" name="aireply" value="${sceneItem.content!''}">
						<div class="layui-input-inline" style="width: 664px;min-height: 26px;color:#000000;border: 1px solid #dedede;padding:5px;" contenteditable="true" onblur="$(this).prev().val($(this).text());">
							${sceneItem.content!''}
						</div>
						<div class="layui-inline">
							<a href="javascript:void(0)" onclick="$('#airp').append($(this).closest('.layui-form-item').prop('outerHTML'));">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#xe608;</i></label>
							</a>
							<#if aireply gt 0>
							<a href="javascript:void(0)" onclick="$(this).closest('.layui-form-item').remove();" class="ukefu-group-remove">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#x1006;</i></label>
							</a>
							</#if>
						</div>
					</div>
					</#if>
					</#list>
					</#if>
					<#if aireply == 0>
					<div class="layui-form-item">
						<label class="layui-form-label">AI回复：</label>
						<input type="hidden" name="aireply" value="">
						<div class="layui-input-inline" style="width: 664px;min-height: 26px;color:#000000;border: 1px solid #dedede;padding:5px;" contenteditable="true" onblur="$(this).prev().val($(this).text());">
						</div>
						<div class="layui-inline">
							<a href="javascript:void(0)" onclick="$('#airp').append($(this).closest('.layui-form-item').prop('outerHTML'));">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#xe608;</i></label>
							</a>
							<a href="javascript:void(0)" onclick="$(this).closest('.layui-form-item').remove();" class="ukefu-group-remove">
								<label style="color:#5FB878;font-size:15px;"><i class="layui-icon">&#x1006;</i></label>
							</a>
						</div>
					</div>
					</#if>
				</div>
			</div>
		</div>

		<div class="layui-form-button">
			<div class="layui-button-block">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</div>

<script>
	layui.use('element', function(){
		var element = layui.element;
	});
	layui.use('form', function() {
		var form = layui.form;
		form.render(); //更新全部
		form.on('switch(bussop)', function(data) {
			if(data.elem.checked == true){
				$("#bussop_tip").show();
			}else{
				$("#bussop_tip").hide();
			}
		});
	});
	$(".ukefu-select").select2({minimumResultsForSearch: Infinity});
</script>